package org.example.task.controller;

import org.example.task.Result;
import org.example.task.domain.Task;
import org.example.task.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("task")
public class TaskController {

    @Autowired
    private TaskService taskService;


    @PostMapping("getTask")
    public Result<Task> getTask(@RequestBody Task task) {
        Task resp = taskService.getTask(task);
        if (ObjectUtils.isEmpty(resp)) {
            return Result.error("未查询到相关任务");
        }
        return Result.success(resp);
    }
}
